package com.kj.platformlogistics.home.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import com.cy.tablayoutniubility.FragPageAdapterVp2;
import com.cy.tablayoutniubility.TabAdapter;
import com.cy.tablayoutniubility.TabLayoutScroll;
import com.cy.tablayoutniubility.TabMediatorVp2;
import com.cy.tablayoutniubility.TabViewHolder;
import com.kj.platformlogistics.R;
import com.kj.platformlogistics.base.BaseActivity;
import com.kj.platformlogistics.home.fragment.WaitSolicilationFragment;

import java.util.ArrayList;
import java.util.List;

public class WaitSolicilationActivity  extends BaseActivity {
    private TabLayoutScroll tab1;
    private ViewPager2 viewpager;

    public static void actionStart(Context context) {
        Intent intent = new Intent(context, WaitSolicilationActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_wait_solicitation;
    }

    @Override
    protected void initView() {
        setTitleText("待揽件");
        tab1=findViewById(R.id.tab1);
        viewpager=findViewById(R.id.viewpager);
        FragPageAdapterVp2<String> fragmentPageAdapter = new FragPageAdapterVp2<String>(this) {

            @Override
            public Fragment createFragment(String bean, int position) {
                switch (position) {
                    case 0://全部
                        return   WaitSolicilationFragment.newInstance(0,0);
                    case 1://待付款
                        return   WaitSolicilationFragment.newInstance(1,0);
                }
                return null;
            }

            @Override
            public void bindDataToTab(TabViewHolder holder, int position, String bean, boolean isSelected) {
                TextView textView = holder.getView(R.id.tv);
                if (isSelected) {
                    textView.setTextColor(0xff333333);
                    textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                    textView.setTextSize(17);
                } else {
                    textView.setTextColor(0xff999999);
                    textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
                    textView.setTextSize(14);
                }
                textView.setText(bean);
            }

            @Override
            public int getTabLayoutID(int position, String bean) {
                return R.layout.tab_item;
            }
        };
        TabAdapter<String> tabAdapter = new TabMediatorVp2<String>(tab1, viewpager).setAdapter(fragmentPageAdapter);
        List<String> list = new ArrayList<>();
        list.add("平台下单");
        list.add("客户下单");
        fragmentPageAdapter.add(list);
        tabAdapter.add(list);
    }

    @Override
    protected void initData() {

    }

    /**
     * 获取要使用的标题栏样式(此函数由子类重写)
     *
     * @return
     */
    @Override
    protected int getTitleBarType() {
        return 0;
    }
}
